package com.xnyzc.lhy.finance.params.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;

/**
 * <p>
 *     定制化分页接参实体
 * </p>
 * 当前页
 * 从第几条开始查找
 * 一页展示多少条
 * 你想要查询数据总数
 * 是否查询总条数
 * 排序（+id：正序，-id：倒序）
 * Created by 11936 on 2019/7/19.
 * @author c
 */
@Data
public class PageDTO {
    @TableField(exist = false)
    private Long page;

    @TableField(exist = false)
    private Long limit;

    @TableField(exist = false)
    private Long index;

    @TableField(exist = false)
    private Long total;

    @TableField(exist = false)
    private Boolean isSearchCount;

    @TableField(exist = false)
    private String sort;

    public void setPage(Long page) {
        this.page = page;
        if(this.limit == null || this.limit < 1L){
            this.limit = 10L;
        }
        if(this.page == null || this.page < 1L){
            this.page = 1L;
        }
        this.index = (this.page - 1L) * this.limit;
    }

    public void setLimit(Long limit) {
        this.limit = limit;
        if(this.page == null || this.page < 1L){
            this.page = 1L;
        }
        if(this.limit == null || this.limit < 1L){
            this.limit = 10L;
        }
        this.index = (this.page - 1L) * this.limit;
    }
}
